package filter;

import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;

/**
 * https://www.baeldung.com/spring-webflux-filters
 */
@Component
public class FluxFilter implements WebFilter {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
//        We'll implement a WebFilter to add a new header to the response. As a result, all responses should have this behavior:
//        exchange.getResponse().getHeaders().add("web-filter", "web-filter-test");

        ServerHttpResponse response = exchange.getResponse();
        HttpHeaders headers = response.getHeaders();
        System.out.println();
        return chain.filter(exchange);
//        exchange.getRequest().
    }
}
